@extends('admin.base')
@section('css')
<link rel="stylesheet" href="/css/parsley/parsley.css"/>
@parent

@stop



@section('content')

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>自动回复列表</h2>
        <ol class="breadcrumb">
            <li>
                <a href="{{route('/')}}">首页</a>
            </li>
            <li>
                <strong>菜单列表</strong>
            </li>
        </ol>
    </div>

</div>
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>自动回复列表<small>：）</small></h5>

                </div>
                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-md-1">
                            <button type="button" id="loading-example-btn" class="btn btn-white btn-sm"><i class="fa fa-refresh"></i> <a href="{{route('autoreply.index')}}" class="fresh-loading">刷新</a></button>
                        </div>
                    </div>

                    <div class="project-list">

                        <table class="table table-hover">
                            <tbody>
                            @foreach ($items as $reply)
                            <tr>
                                <td class="project-status">
                                    @if($reply->type=='text')
                                    <span class="label label-success">文本</span>
                                    @elseif($reply->type=='news')
                                    <span class="label label-info">图文</span>
                                    @elseif($reply->type=='image')
                                    <span class="label label-inverse">图片</span>
                                    @endif
                                </td>
                                <td class="project-title">
                                    <a href="javascript:void(0);">{{$reply->rulename}}</a>
                                    <br/>
                                    <!--                            <small>{{$reply->keyword}}</small>-->
                                </td>
                                <td class="project-completion">
                                    <small>关键词：{{$reply->keyword}}</small>
                                </td>
                                <td class="project-actions">
                                    <a href="{{route('autoreply.edit',$reply->id)}}" data-id="{{$reply->id}}"  class="btn btn-white btn-sm reply-edit"><i class="fa fa-folder"></i> 编辑 </a>
                                    <a href="javascript:void(0);" data-id="{{$reply->id}}" class="btn btn-white btn-sm  delreply"><i class="fa fa-pencil"></i> 删除 </a>
                                </td>
                            </tr>

                            @endforeach




                            </tbody>
                        </table>
                        <?php echo $items->render();?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@stop

@section('script')
@parent
<!--<script src="/js/sweetalert/sweetalert.min.js"></script>-->
<script src="/js/sweetalert/sweetalert.min.js"></script>
<script>
    $('.delreply').on('click', function() {
        $replyId = $(this).data('id');
        console.log($replyId);
        swal({
                title: "不要冲动",
                text: "你确定要删除这条自动回复吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定!",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                showLoaderOnConfirm: true
            },
            function(){
                $.ajax({
                    url : "{{route('autoreply.destroy')}}",
                    type: 'DELETE',
                    data:{'replyid':$replyId},
                    success: function(data) {
                        if(data.code==2000) {
                            swal("成功!请点下刷新按钮~", data.message, "success");
                        }else {
                            swal("失败!", data.message, "error");
                        }
                    }
                });

            }
        );
    });

</script>
@stop
